<?php 
define('__ROOT__', dirname(dirname(__FILE__))); 
include_once(__ROOT__.'/includes/header.php'); 
include_once(__ROOT__.'/includes/leftnav.php'); 
			if (isset($message)){
			echo '<div class="alert alert-info">';
			echo '<a class="close"></a>';
			echo $message;
			echo '</div>';
		}
?>

<div id="content" class="span10">
	
	<ul class="breadcrumb">
					<li>
						<a href="<?php echo base_url('/home'); ?>">Home</a> <span class="divider">/</span>
					</li>
					<li>
						<a href="<?php echo base_url('/admin/dashboard'); ?>">Dashboard</a>
					</li>
	</ul>
	
	<div class="row-fluid sortable">
		
		<div class="box span6">
			<div class="box-header dashwell">
				<h2>
					<i class="icon-star"></i> My Ads Stats Year To date
				</h2>
				<div class="box-icon">
					<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i>
					</a> <a href="#" class="btn btn-minimize btn-round"><i
						class="icon-chevron-up"></i> </a> <a href="#"
						class="btn btn-close btn-round"><i class="icon-remove"></i> </a>
				</div>
			</div>
			<div class="box-content">
				<div class="span10">
					<div class="span3 offset1">
						 <h1><?php echo $classifieds_count; ?></h1>
						 <span calss="stats-value">Classifieds</span><br/>
						 <span class="classifiedsbar">Loading..</span>

					</div>
					<div class="span3 offset1">
						<h1><?php echo $property_count; ?></h1>
						<span calss="stats-value">Property</span><br/>
						<span class="propertybar">Loading..</span>
					</div>
					<div class="span3 offset1">
						<h1><?php echo $automobile_count; ?></h1>
						<span calss="stats-value">Car and Vehicles</span><br/>
						<span class="autobar">Loading..</span>
					</div>
					<div id="piechart" style="height:265px"></div>
				</div>
			</div>
		</div>
		<div class="box span6">
			<div class="box-header dashwell">
				<h2>
					<i class="icon-bookmark"></i> Quick Shortcuts
				</h2>
				<div class="box-icon">
					<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i>
					</a> <a href="#" class="btn btn-minimize btn-round"><i
						class="icon-chevron-up"></i> </a> <a href="#"
						class="btn btn-close btn-round"><i class="icon-remove"></i> </a>
				</div>
			</div>
			<div class="box-content">
				<div class="span12 well">
					<a data-rel="tooltip" title="6 new members."
						class="well span4 top-block" href="<?php echo site_url("/admin/classifieds/post"); ?> "> <span
						class="icon-bullhorn icon-green "></span>
						<div>Post </div>
						<div>Buy/Sell</div>
					</a> 
					<a data-rel="tooltip" title="6 new members."
						class="well span4 top-block" href="<?php echo base_url('/admin/property/post'); ?>"> <span
						class="icon-home"></span>
						<div>Post </div>
						<div>Property</div> 
					</a>
					<a data-rel="tooltip" title="6 new members."
						class="well span4 top-block" href="<?php echo base_url('/admin/automobiles/post'); ?>"> <span
						class=" icon-tasks icon-red"></span>
						<div>Post</div>
						<div>Automobiles</div>
					</a>
				</div>
				<div class="span12 offset1">
					<a data-rel="tooltip" title="6 new members."
						class="well span5 top-block" href="<?php echo base_url('/admin/articles/post'); ?>"> <span
						class="icon32 icon-red icon-edit"></span>
						<div>Write</div>
						<div>Articles</div> 
					</a> 
					<a data-rel="tooltip" title="6 new members."
						class="well span5 top-block" href="<?php echo base_url('/admin/profile') . '/update/' . $this->session->userdata('userid'); ?>"> <span
						class="icon32 icon-blue icon-user"></span>
						<div>Change </div>
						<div>Profile</div>
					</a>
				</div>
			</div>
		</div>
		</div>
		<div class="row-fluid sortable"> 
		<div class="box span6">
			<div class="box-header dashwell">
				<h2>
					<i class="icon-list-alt"></i> Recent News
				</h2>
				<div class="box-icon">
					<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i>
					</a> <a href="#" class="btn btn-minimize btn-round"><i
						class="icon-chevron-up"></i> </a> <a href="#"
						class="btn btn-close btn-round"><i class="icon-remove"></i> </a>
				</div>
			</div>
			<div class="box-content">
			 <?php foreach($news as $new): ?>
              <li class="news-item"><?php echo $new; ?></li>
            <?php endforeach ?>
			</div>
		</div>
		<div class="box span6">
			<div class="box-header dashwell">
				<h2>
					<i class="icon-signal"></i> Charts
				</h2>
				<div class="box-icon">
					<a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i>
					</a> <a href="#" class="btn btn-minimize btn-round"><i
						class="icon-chevron-up"></i> </a> <a href="#"
						class="btn btn-close btn-round"><i class="icon-remove"></i> </a>
				</div>
			</div>
			<div class="box-content">
			<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
			</div>
		</div>
		<!--/row-->

	</div>
</div>
<?php 
include_once(__ROOT__.'/includes/footer.php');
?>
 <script type="text/javascript" src="<?php echo base_url("assets/js/jquery.sparkline.min.js"); ?>"></script>
 <script type="text/javascript" src="<?php echo base_url("assets/js/highcharts.js"); ?>"></script>
 <script>
 $(function () {
    $('#container').highcharts({
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'The percentage between advertisements'
        },
        tooltip: {
    	    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
            }
        },
        series: [{
            type: 'pie',
            name: 'Browser share',
            data: [
                ['Classifieds',   <?php echo $classifiendpercent;?>],
                ['Property',       <?php echo $propertypercent;?>],
                ['Car & Vehicles',    <?php echo $autopercent;?>]
               
            ]
        }]
    });
});
 $(function() {
        /** This code runs when everything has been loaded on the page */
        /* Inline sparklines take their values from the contents of the tag */
        
        var statsurl = 'http://localhost/maykha/admin/dashboard/statistics';
        
        /* Sparklines can also take their values from the first argument 
        passed to the sparkline() function */
       
        var msgData = {
						'advertiserID': 65,
						'model': 'Classified_model'
					}
					$.ajax({
						type: "post",
						url: statsurl,
						cache: false,
						data: msgData,
						success: function(data) {
							//alert(data);
							//var myvalues = $.parseJSON(data);
							createJSTrees($.parseJSON(data));
							//result = data;

						},
						error : function(xhr, ajaxOptions, thrownError) {
				            alert(thrownError);
				        }
		});
       
    });
	function createJSTrees(myvalues) {
     /*var myvalues = [10,8,5,7,4,4,1];*/
     	$('.inlinesparkline').sparkline(); 
        //var myvalues = result;
        $('.dynamicsparkline').sparkline(myvalues);

        /* The second argument gives options such as chart type */
        $('.classifiedsbar').sparkline(myvalues, {type: 'bar', barColor: 'green'} );
        $('.propertybar').sparkline(myvalues, {type: 'bar', barColor: 'blue'} );
        $('.autobar').sparkline(myvalues, {type: 'bar', barColor: 'red'} );

        /* Use 'html' instead of an array of values to pass options 
        to a sparkline with data in the tag */
        $('.inlinebar').sparkline('html', {type: 'bar', barColor: 'red'} );
    
	}
 </script>